package com.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

// extends WebMvcConfigurerAdapter  这是springboot1.x
// implements WebMvcConfigurer      这是springboot2.x
@Configuration
public class ImageMapper extends WebMvcConfigurerAdapter {

    @Value("${upload.dir}")
    private  String images;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/images/**").addResourceLocations("file:"+images);

    }
}
